package com.ldzy.controller;

import com.ldzy.domain.Login;
import com.ldzy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;
    @RequestMapping("/loginController/homePage")
    public String homePage(Login login, HttpSession session){
        Login login1=loginService.doLogin(login);
        System.out.println(login1);
        if(login1!=null)  {
            session.setAttribute("login",login1);
            return "/pages/homePage";
        }
        else {
            return "/pages/error";
        }
    }

    @RequestMapping("/login")
    public String login(){
        return "/pages/login";
    }


//
//    @RequestMapping("/a")
//    public String a(){
//        return "pages/a";
//    }
}
